import request from './request.js'
class getData {
  constructor() {
    this._baseUrl = 'https://a.v2too.com/wdt/'
    //this._baseUrl = 'http://10.1.67.194/'
    this._defaultHeader = { 'Content-Type': 'application/json' }
    this._request = new request
    this._request.setErrorHandler(this.errorHander);
  }

  /**
   * 统一的异常处理方法
   */
    errorHander(res) {
      console.error(res)
    }
    mine(open_id){
      const params = open_id;
      return this._request.getRequest(this._baseUrl + 'wx/mine', params).then(res => res.data);
    }
    activities(params) {
      return this._request.getRequest(this._baseUrl + 'wx/con/mine_consults', params).then(res => res.data)
    }
    getCollects(params) {
      return this._request.getRequest(this._baseUrl + 'wx/follow/collects', params).then(res => res.data)
    }
    getHistoriesList(params) {
      return this._request.getRequest(this._baseUrl + 'wx/hist/histories',params).then(res => res.data)
    }
    actDetail(params){
      return this._request.getRequest(this._baseUrl + 'act/actDetail', params).then(res => res.data);
    }
    addConsult(params){
      return this._request.postRequest(this._baseUrl + 'cons/addConsult', params).then(res => res.data);
    }
    assDetail(params){
      return this._request.getRequest(this._baseUrl + 'act/assDetail', params).then(res => res.data);
    }
    artDetail(params){
      return this._request.getRequest(this._baseUrl + '/art/artDetail', params).then(res => res.data);
    }
    addCollection(params){
      return this._request.postRequest(this._baseUrl+'col/addCollection',params).then(res=>res.data);
    }
    getTeas(pageIndex,pageSize ){
      const params ={pageIndex:pageIndex,pageSize:pageSize}
      return this._request.getRequest(this._baseUrl + '/tea/getTeas', params).then(res => res.data);
    }
    add_del_Collection(params){
      return this._request.getRequest(this._baseUrl + '/col/add_del_Collection', params).then(res => res.data);
    }
    workShopDetail(params){
      return this._request.postRequest(this._baseUrl+'audio/workShopDetail',params).then(res=>res.data);
    }
    recommendDatas(params){
      return this._request.postRequest(this._baseUrl+'ws/recommendDatas',params).then(res=>res.data);
    }
    partnerByOpenId(params){
      return this._request.postRequest(this._baseUrl+'art/partnerByOpenId',params).then(res=>res.data);
    }
    enrolls(params){
      return this._request.postRequest(this._baseUrl+'audio/enrolls',params).then(res=>res.data);
    }
    articles(params){
      return this._request.getRequest(this._baseUrl+'art/articles',params).then(res=>res.data);
    }
}
export default getData